<template>
  <div class="page-login">
    <el-form ref="formRef" :model="form" class="form-box" :rules="rules">
      <div class="title">用户登录</div>
      <el-form-item prop="name">
        <my-icon icon="user" color="#ddd" size="18"></my-icon>
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item prop="pwd">
        <my-icon icon="password" color="#ddd" size="18"></my-icon>
        <el-input v-model="form.pwd"></el-input>
      </el-form-item>
      <el-button type="primary" @click="handleLogin">登录</el-button>
    </el-form>
  </div>
</template>
<script setup>
import {reactive, ref} from "vue";
const form = reactive({
  name: '',
  pwd: ''
});
const rules = reactive({
  name: [{required: true, message: '请输入用户名', trigger: 'blur'},],
  pwd: [{required: true, message: '请输入密码', trigger: 'blur'},],
});
const formRef = ref(null);
const handleLogin = () => {
  formRef.value.validate(flag => {
    if (flag) {
      console.log('ok');
    } else {
      console.log('err');
    }
  });
};
</script>
<style lang="scss">
.page-login {
  background-color: #2c394c;
  display: flex;
  justify-content: center;
  align-items: center;
  .form-box {
    width: 700px;
    .title {
      font-size: 44px;
      color: #fff;
      text-align: center;
      margin-bottom: 30px;
    }
    .el-form-item {
      margin-bottom: 30px;
    }
    .el-form-item__content {
      height: 50px;
      display: flex;
      align-items: center;
      background-color: #283344;
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 5px;
      padding: 15px 10px;
      .el-icon {
        color: #aaa;
        font-size: 24px;
      }
      .el-input {
        flex: 1;
        .el-input__wrapper {
          background-color: #283344;
          box-shadow: none;
        }
      }
      input {
        color: white;
        text-align: center;
        &:-webkit-autofill, {
          -webkit-box-shadow: 0 0 0 1000px #283344 inset;
        }
      }
    }
    .el-button {
      width: 100%;
      height: 50px;
      font-size: 18px;
    }
  }
}
</style>